package zhklappoint.initsys;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import zhklappoint.ZhklAppointApplication;


@Configuration
@ComponentScan(basePackageClasses = ZhklAppointApplication.class, useDefaultFilters = true)
public class ServiceInterceptors implements WebMvcConfigurer {

	@Bean
	public MiddleInterceptors appInterceptors() {
		return new MiddleInterceptors();
	}
	
//	@Override
//	public void addViewControllers(ViewControllerRegistry registry) {
//		registry.addViewController("/").setViewName("index");
//		registry.addViewController("/index.html").setViewName("index");
//		registry.addViewController("/main").setViewName("dashboard");
//	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		
		registry.addInterceptor(appInterceptors())
		.addPathPatterns("/**")
			.excludePathPatterns("/")
			.excludePathPatterns("/img/**")
			.excludePathPatterns("/css/**")
			.excludePathPatterns("/backimg/**")
			.excludePathPatterns("/js/**")
			.excludePathPatterns("/free**");
		
	}

	@Override
	public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
		configurer.enable();
	}
	
}
